﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace YayiMgr.EntityFrameworkCore.Migrations
{
    /// <inheritdoc />
    public partial class _03 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "SupplierName",
                table: "Suppliers",
                type: "varchar(100)",
                maxLength: 100,
                nullable: true,
                comment: "供应商名称",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldComment: "供应商名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "Phone",
                table: "Suppliers",
                type: "varchar(20)",
                maxLength: 20,
                nullable: true,
                comment: "联系电话",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldComment: "联系电话")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "ContactName",
                table: "Suppliers",
                type: "varchar(20)",
                maxLength: 20,
                nullable: true,
                comment: "联系人姓名",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldComment: "联系人姓名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<Guid>(
                name: "CompanyId",
                table: "Suppliers",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                comment: "企业ID",
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "DailiId",
                table: "Suppliers",
                type: "char(36)",
                nullable: true,
                comment: "代理公司的ID",
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<bool>(
                name: "IsDaili",
                table: "Suppliers",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "是否是代理");

            migrationBuilder.AddColumn<bool>(
                name: "IsRoot",
                table: "Suppliers",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "是否是根节点，在列表中展示");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "CompanyId",
                table: "Suppliers");

            migrationBuilder.DropColumn(
                name: "DailiId",
                table: "Suppliers");

            migrationBuilder.DropColumn(
                name: "IsDaili",
                table: "Suppliers");

            migrationBuilder.DropColumn(
                name: "IsRoot",
                table: "Suppliers");

            migrationBuilder.UpdateData(
                table: "Suppliers",
                keyColumn: "SupplierName",
                keyValue: null,
                column: "SupplierName",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "SupplierName",
                table: "Suppliers",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                comment: "供应商名称",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldNullable: true,
                oldComment: "供应商名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "Suppliers",
                keyColumn: "Phone",
                keyValue: null,
                column: "Phone",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "Phone",
                table: "Suppliers",
                type: "varchar(20)",
                maxLength: 20,
                nullable: false,
                comment: "联系电话",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldNullable: true,
                oldComment: "联系电话")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "Suppliers",
                keyColumn: "ContactName",
                keyValue: null,
                column: "ContactName",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "ContactName",
                table: "Suppliers",
                type: "varchar(20)",
                maxLength: 20,
                nullable: false,
                comment: "联系人姓名",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldNullable: true,
                oldComment: "联系人姓名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
